<?php  
    if(isset($_POST["submit"]))  
    {  
        $telphone = $_POST["telphone"];  
        $password = $_POST["password"];  
        if($telphone == "" || $password == "")  
        {  
            echo "<script>alert('请输入手机号或密码！'); history.go(-1);</script>";  
        }  
        else  
        {  
        	mysql_connect("localhost:3306","root","root");   //连接数据库
        	mysql_select_db("petcircle");  //选择数据库
        	mysql_query("set names 'utf-8'"); //设定字符集
            $sql = "select telphone, username,password from pet_u_m_user where telphone = '$_POST[password]' and password = '$_POST[password]'";  
            $result = mysql_query($sql);  
            $num = mysql_num_rows($result);  
            if($num)  
            {  
                $row = mysql_fetch_array($result);  //将数据以索引方式储存在数组中  
                echo "<script>alert('Welecome! $row[1]');</script>";//$row[1]是指数组的第二个数
            	
                echo '<script>window.location.href="'.site_url("home/index").'";</script>';   
            }  
            else  
            {  
                echo "<script>alert('手机号码或密码不正确！');history.go(-1);</script>";  
            }  
        }  
    }  
    else  
    {  
        echo "<script>alert('提交未成功！'); history.go(-1);</script>";  
    }  
  
?>  
